package cn.zxinrun.wps.plugins.policy;

import com.deepoove.poi.policy.AbstractRenderPolicy;
import com.deepoove.poi.render.RenderContext;
import org.apache.poi.xwpf.usermodel.BreakType;
import org.apache.poi.xwpf.usermodel.XWPFRun;

/**
 * 分页符策略
 * @author Mr.Zhang
 * @since 1.0
 **/
public class BreakAbstractRenderPolicy extends AbstractRenderPolicy<Boolean> {

    /**
     * 渲染分页符
     * @param context 渲染上下文
     * @throws Exception 异常信息
     */
    @Override
    public void doRender(RenderContext<Boolean> context) throws Exception {
        XWPFRun where = context.getWhere();
        Boolean thing = context.getThing();
        where.setText("", 0);
        if (thing != null && thing) {
            where.addBreak(BreakType.PAGE);// 添加一个分页符
        }
    }

}
